﻿
function ClientSearchLawDocument(belongSite,LawDocumentId) {
                                                         
     document.getElementById("divProcessing").innerHTML= Portal.SODC.WebSite.LawDocument.GetProcessingText().value;
     setTimeout("RealClientSearchLawDocument('"+belongSite+"','"+LawDocumentId+"')",10);
}

function RealClientSearchLawDocument(belongSite,LawDocumentId)
{
     Code=document.getElementById("txtCode").value;
     Subject=document.getElementById("txtSubject").value;
     LawDocumentOfficeId=document.getElementById("drpSelectLawDocumentOffice").options[document.getElementById("drpSelectLawDocumentOffice").selectedIndex].value;
     LawDocumentTypeId=document.getElementById("drpSelectLawDocumentType").options[document.getElementById("drpSelectLawDocumentType").selectedIndex].value;
     LawDocumentSignerId=document.getElementById("drpSelectLawDocumentSigner").options[document.getElementById("drpSelectLawDocumentSigner").selectedIndex].value;
     PageIndex=0;
     if(document.getElementById("txtPageIndex")!=null)
     {
        PageIndex=document.getElementById("txtPageIndex").value;
     }
     
     retValue=Portal.SODC.WebSite.LawDocument.Search(LawDocumentId,belongSite,Code, Subject, LawDocumentSignerId, LawDocumentTypeId, LawDocumentOfficeId,PageIndex).value;
     if(retValue.indexOf("ERROR")!=-1)
     {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
     }
     document.getElementById("divProcessing").innerHTML="";
     document.getElementById("divFormResult").innerHTML=retValue;
}



function DownloadLawDocumentItem(LawDocumentItemId)
{
     Url=Portal.SODC.WebSite.LawDocument.ServerSideDownloadItem(LawDocumentItemId).value;
     if(Url.indexOf("ERROR")!=-1)
     {
        alert(Url);
        return;
     }
     //window.open(Url,"_self");
     ot = Portal.SODC.WebSite.LawDocument.CheckOpenType(Url).value;
     if(ot==1)
     {
        window.showModalDialog(Url, null, 'dialogHeight: 400px; dialogWidth: 580px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
     }
     else
     {
        window.open(Url,"_blank");
     }
}


function DownloadAllLawDocumentItem(LawDocumentItemId) {
    Url = Portal.SODC.WebSite.AllLawDocument.ServerSideDownloadItem(LawDocumentItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.open(Url,"_self");
    ot = Portal.SODC.WebSite.AllLawDocument.CheckOpenType(Url).value;
    if (ot == 1) {
        window.showModalDialog(Url, null, 'dialogHeight: 400px; dialogWidth: 580px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    }
    else {
        window.open(Url, "_blank");
    }
}

function DownloadLawDocumentItemFromView(LawDocumentItemId) {
    Url = Portal.SODC.WebSite.ViewLawDocument.ServerSideDownloadItem(LawDocumentItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.open(Url,"_self");
    ot = Portal.SODC.WebSite.ViewLawDocument.CheckOpenType(Url).value;
    if (ot == 1) {
        window.showModalDialog(Url, null, 'dialogHeight: 400px; dialogWidth: 580px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    }
    else {
        window.open(Url, "_blank");
    }
}

function KeyPressForSearch(myfield,e,belongSite) 
{ 
    var keycode; 
    if (window.event) keycode = window.event.keyCode; 
        else if (e) keycode = e.which; 
            else return true; 
    if (keycode == 13) 
    { 
        ClientDoSimpleSearch(belongSite) 
        return false; 
    } 
    else 
    { 
        return true; 
    } 
}

function ClientOpenLawDocumentItem(belongSite,LawDocumentItemId) {
    Url = Portal.SODC.WebSite.LawDocument.GetOpenDetailUrl(belongSite, LawDocumentItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 400px; dialogWidth: 580px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, "_blank");
}


function ClientOpenAllLawDocumentItem(belongSite, LawDocumentItemId) {
    Url = Portal.SODC.WebSite.AllLawDocument.GetOpenDetailUrl(belongSite, LawDocumentItemId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}


function JumpPageLawDocumentItem(LawDocumentId, MaxItems, ItemsPerRow, VisiblePage, CurrentPageIndex, Javascript) {
    Code = document.getElementById("txtCode").value;
    Subject = document.getElementById("txtSubject").value;
    LawDocumentOfficeId = document.getElementById("drpSelectLawDocumentOffice").options[document.getElementById("drpSelectLawDocumentOffice").selectedIndex].value;
    LawDocumentTypeId = document.getElementById("drpSelectLawDocumentType").options[document.getElementById("drpSelectLawDocumentType").selectedIndex].value;
    LawDocumentSignerId = document.getElementById("drpSelectLawDocumentSigner").options[document.getElementById("drpSelectLawDocumentSigner").selectedIndex].value;
    belongSite = document.getElementById("txtBelongSite").value;
    retValue = Portal.SODC.WebSite.LawDocument.Search(LawDocumentId, belongSite, Code, Subject, LawDocumentSignerId, LawDocumentTypeId, LawDocumentOfficeId, CurrentPageIndex).value;
    document.getElementById("divFormResult").innerHTML = retValue;
}

function JumpPageAllLawDocumentItem(LawDocumentId, MaxItems, ItemsPerRow, VisiblePage, CurrentPageIndex, Javascript) {
    belongSite = document.getElementById("txtBelongSite").value;
    retValue = Portal.SODC.WebSite.AllLawDocument.Search(LawDocumentId, belongSite, CurrentPageIndex).value;
    document.getElementById("divFormResult").innerHTML = retValue;
}